package me.blog.markan.android.desktop.web;

import java.io.InputStream;
import java.util.HashMap;
import java.util.StringTokenizer;

public class HttpWebRequest {
	
	private InputStream is = null;
	private String resName = null;	
	private HashMap<String, String> requestMap = new HashMap<String, String>();
	
	public HttpWebRequest(String res) {
		
		if (res.indexOf("?") > 0) {
			resName = res.substring(0, res.indexOf("?"));
			
			res = res.substring(res.indexOf("?") + 1);
			StringTokenizer st = new StringTokenizer(res, "&");
			while (st.hasMoreTokens()) {
				String opt = st.nextToken();
				if (opt.indexOf("=") > 0)
					requestMap.put(opt.substring(0, opt.indexOf("=")), opt.substring(opt.indexOf("=") + 1));
				else
					requestMap.put(opt, "~");
			}
		} else {
			this.resName = res;
		}
	}
	
	public String getParameter(String key) {
		return requestMap.get(key);
	}
	
	public String getResName() {
		return this.resName;
	}
}
